package JavaBean;

import java.lang.reflect.Field;

public class AccessPersonFields {
    public static void main(String[] args) {
        try{
            Class cls = Class.forName("JavaBean.Person");
            Object obj = cls.newInstance();
            Field name = cls.getDeclaredField("name");
            name.setAccessible(true);
            System.out.println("赋值前的mame : " + name.get(obj));
            name.set(obj, "New Person");
            System.out.println("赋值后的name : " + name.get(obj));
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
